package com.shj.em.biz.sell.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.shj.em.biz.sell.dto.OrderSearchDTO;
import com.shj.em.biz.sell.entity.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单信息 Mapper 接口
 * </p>
 *
 * @author Shen Huang Jian
 * @since 2018-07-09
 */
@Mapper
public interface OrderMapper extends BaseMapper<Order> {
    /**
     * 分页查询
     * @param page 分页信息
     * @return
     */
    List<Order> queryOrderPage(Page<Order> page, OrderSearchDTO searchDTO);

    Order findOrderByOrderNo(String orderNo);

    List<Order> findOrdersByDatePrefix(String datePrefix);

    /**
     * 对于一些加单的情况，比如原来的订单号是 18051501, 后续要追加数量，
     * 不修改原来的订单，新的订单号在原来的订单号后再加序号。如：18051501-01
     * @param orderNo
     * @return
     */
    String getMaxOrderNoByOrderNo(String orderNo);

    List<Order> getOrderAmountList(@Param("yearBegin")String yearBegin, @Param("yearEnd")String yearEnd);

    List<Order> getAmountPerMonthInYear(@Param("yearBegin")String yearBegin, @Param("yearEnd")String yearEnd);

    List<Map<String, Object>> getReturnAmountPerMonthInYear(@Param("yearBegin")String yearBegin, @Param("yearEnd")String yearEnd);

    void updatePlanPayDate();

    List<Map<String, Object>> getShouldReturnPerMonthInYear(@Param("yearBegin")String yearBegin, @Param("yearEnd")String yearEnd);

    /**
     * 设置完成生产
     */
    void updateToFinishProduce(@Param("orderId") Long orderId);

    void closeOrder(@Param("orderId") Long orderId);

    List<Order> findHasWorkHourOrdersInYear(@Param("yearBegin")String yearBegin, @Param("yearEnd")String yearEnd);

    /**
     * 获得员工某段时间内员工花费时间的订单的信息, 包含以下几个字段信息：
     * id, order_no, total_amount, shipment_status
     * @param begin
     * @param end
     * @param empId
     * @return
     */
    List<Order> getEmpWorkOrders(@Param("begin") String begin, @Param("end") String end, @Param("empId") Long empId);


}
